package com.spzx.test1.t10;
/*
    并非全力
*/

public class MyThread {

    public int i = 0;

    public synchronized void A() throws InterruptedException {
        while (i != 0) {
            this.wait();
        }
        i++;
        System.out.println(Thread.currentThread().getName() + ":" + i);
        this.notifyAll();
    }

    public synchronized void B() throws InterruptedException {
        while (i == 0) {
            this.wait();
        }
        i--;
        System.out.println(Thread.currentThread().getName() + ":" + i);
        this.notifyAll();

    }
}